﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Core
{
    public enum Type
    {
        Z,
        N,
        N1,
        R,
        Q,
        B,
        Char
    }

    public enum Language
    {
        CSharp,
        CPlusPlus,
        VB,
        VBNET,
        Java,
        Ruby
    }

    // TODO: DataType shouldn't care about programming language
    //       MapToLanguage method

    /// <summary>
    /// Data type
    /// </summary>
    public class DataType
    {
        private Type _Type;

        public DataType(String type)
        {
            try
            {
               _Type = (Type)Enum.Parse(typeof(Type), type);
            }
            catch (Exception)
            {
                throw new NotSupportedException();
            }
        }

        /// <summary>
        /// Map data type to language
        /// </summary>
        public String MapToLanguage(Language language)
        {
            switch (language)
            {
                // C#
                case Language.CSharp:
                    switch (_Type)
                    {
                        case Type.N:
                        case Type.N1:
                        case Type.Z:
                            return "Int32";

                        case Type.R:
                        case Type.Q:
                            return "Double";

                        case Type.B:
                            return "Boolean";

                        case Type.Char:
                            return "Char";
                    }
            	    break;

                // C++
                case Language.CPlusPlus:
                    switch (_Type)
                    {
                        case Type.N:
                        case Type.N1:
                        case Type.Z:
                            return "int";

                        case Type.R:
                        case Type.Q:
                            return "double";

                        case Type.B:
                            return "bool";

                        case Type.Char:
                            return "char";
                    }
                    break;

                case Language.VB:
                    break;
            }

            throw new NotSupportedException();
        }
    }   
}
